package com.wanmait.hotelManage.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Time;
import java.sql.Timestamp;

import com.wanmait.hotelManage.util.DBHelper;
import com.wanmait.hotelManage.vo.RoomType;
import com.wanmait.hotelManage.vo.Userinfo;

public class OrderRoomTypeDAO {
	private OrderRoomTypeDAO() {};
	private static OrderRoomTypeDAO orderroomtypedao=new OrderRoomTypeDAO();
	public static OrderRoomTypeDAO getOrderroomtypedao() {
		return orderroomtypedao;
	}
	public void addOrder(Userinfo userinfo,String phone,Timestamp ydata,Timestamp tdata,RoomType roomtype)
	{
	Connection conn=null;
	PreparedStatement ps=null;
	ResultSet rs=null;
	String sql="INSERT INTO `orders` (userinfo_id,name,telephone_number,start_time,end_time,room_type_id)VALUES(?,?,?,?,?,?)";
	try {
		conn=DBHelper.getDBHelper().getConn();
		ps=conn.prepareStatement(sql);
		ps.setInt(1, userinfo.getId());
		ps.setString(2, userinfo.getUsername());
		ps.setString(3, phone);
		ps.setTimestamp(4,ydata);
		ps.setTimestamp(5, tdata);
		ps.setInt(6,roomtype.getId());
		ps.executeUpdate();
	} catch (Exception e) {
		e.printStackTrace();
		// TODO: handle exception
	}	
	finally {
		DBHelper.getDBHelper().close(null, ps, conn);
	}
	}
}
